package club.dmyang.service;

import club.dmyang.dao.CarouselMapper;
import club.dmyang.entity.Carousel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by brss on 2018/8/17.
 */
@Service("carouselService")
public class CarouselServiceImpl implements CarouselService{


    @Autowired
    private CarouselMapper carouselMapper;

    /**
     * 用id查
     *
     * @param id
     * @return
     */
    @Override
    public Carousel findOneById(Integer id) {
        return carouselMapper.selectByPrimaryKey(id);
    }

    /**
     * 查询所有
     *
     * @return
     */
    @Override
    public List<Carousel> findAll() {
        return carouselMapper.selectAll();
    }

    /**
     * 更新
     *
     * @param carousel
     * @return
     */
    @Override
    public boolean updateOneById(Carousel carousel) {
        return carouselMapper.updateByPrimaryKeySelective(carousel)!=0;
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public boolean delOneById(Integer id) {
        return carouselMapper.deleteByPrimaryKey(id)!=0;
    }

    /**
     * 添加一条
     *
     * @param carousel
     * @return
     */
    @Override
    public boolean addOne(Carousel carousel) {
        return carouselMapper.insert(carousel)!=0;
    }
}
